package com.itheima02.many_to_many;

import com.itheima02.bean.Course;
import com.itheima02.bean.Student;
import com.itheima02.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

public class Test03 {

    @Test
    public void findAll(){
        SqlSession sqlSession = MyBatisUtils.getSqlSession();
        StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
        List<Student> list = mapper.findAll();
        for (Student student : list) {
            System.out.println(student.getId()+","+student.getName()+","+student.getAge());
            List<Course> courses = student.getCourses();
            for (Course cours : courses) {
                System.out.println(cours);
            }
        }
    }
}
